#!/usr/bin/perl
use warnings;
use strict;

use Test::More tests => 7;

my @files = qw(hello loader primes tsort josephus1 mystery stress);
my $mixal_dir = "../mixal" if -d "../mixal";
$mixal_dir = "mixal" if -d "mixal";
my $mixasm = "../mixasm.pl" if -f "../mixasm.pl";
$mixasm = "mixasm.pl" if -f "mixasm.pl";

foreach (@files)
{
    my $t = $_;
    unlink "$t.crd";
    unlink "$t.lst";
    unlink "$t.crd.diff";
    unlink "$t.lst.diff";
    system("perl $mixasm $mixal_dir/$t");
    my $crddiff = system("diff $mixal_dir/$t.crd $t.crd > $t.crd.diff");
    my $lstdiff = system("diff $mixal_dir/$t.lst $t.lst > $t.lst.diff");
    unlink "$t.crd.diff" if $crddiff == 0;
    unlink "$t.lst.diff" if $lstdiff == 0;
    ok($crddiff == 0 && $lstdiff == 0, $t);
}
